"""
默认抽取策略，采用requests
"""
import requests

from com.data.exception.exception import UnSupportHttpMethodException
from com.data.extract import Strategy


class DefaultStrategy(Strategy.Strategy):

    def post(self, http_request):
        return requests.post(url=http_request.url, data=http_request.params, headers=http_request.request_header,
                             cookies=http_request.cookie)

    def get(self, http_request):
        return requests.get(url=http_request.url, params=http_request.params, headers=http_request.request_header,
                            cookies=http_request.cookie)

    def head(self, http_request):
        return requests.head(url=http_request.url, params=http_request.params, headers=http_request.request_header,
                             cookies=http_request.cookie)

    def options(self, http_request):
        return requests.options(url=http_request.url, params=http_request.params, headers=http_request.request_header,
                                cookies=http_request.cookie)

    def put(self, http_request):
        raise UnSupportHttpMethodException.UnSupportHttpMethodException()

    def patch(self, http_request):
        raise UnSupportHttpMethodException.UnSupportHttpMethodException()

    def delete(self, http_request):
        raise UnSupportHttpMethodException.UnSupportHttpMethodException()

    def trace(self, http_request):
        raise UnSupportHttpMethodException.UnSupportHttpMethodException()

    def connect(self, http_request):
        raise UnSupportHttpMethodException.UnSupportHttpMethodException()
